<%@ page contentType="text/html;charset=UTF-8"%>
<%@include file="../../common/sessionValidate.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html lang="UTF-8">
  <head>
    <title>T_bussines_apply信息维护</title>
    <%@ include file="../../common/meta.jsp"%>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="X-UA-Compatible" content="IE=9">
	<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <link rel="stylesheet" href="<%=basePath%>css/my-bootstrap.css" media="screen"  id="tuserskin">
    <link rel="stylesheet" href="<%=basePath%>js/toastr/toastr.css">
    <link rel="stylesheet" href="<%=basePath%>css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="<%=basePath%>css/font-awesome.min.css">
    <script type="text/javascript" src="<%= basePath %>js/jquery.cookie.js"></script>
  </head>
  <style>
hr {
    margin-top:1px;
    border-bottom: 1px solid #1BBC9B;
}
  </style>
<body>
<div>
 <!-------------------------- 面板  start--------------------------------->
 <form class="form-horizontal form-bordered form-row-strippe" name="ffAdd" id="ffAdd" mentod="post" role="form" data-toggle="validator" enctype="multipart/form-data">
  <div class="" style="margin-right:2px;padding-right:1px;"> 
	<div class="panel panel-primary" >
	  <div class="panel-heading clearfix"  id="addHeaderDiv">
	  </div>
	  <div class="panel-body">
           <div class="row" >
                <h5>&nbsp;&nbsp;基本信息</h5>
	            <hr>
            	<div class="col-xs-6"><!--start 换列-->
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> applyid</label>
                            <div class="col-xs-9">
                                <input id="applyid" name="applyid" type="text" class="form-control" placeholder="applyid" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> companyid</label>
                            <div class="col-xs-9">
                                <input id="companyid" name="companyid" type="text" class="form-control" placeholder="companyid" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> companyname</label>
                            <div class="col-xs-9">
                                <input id="companyname" name="companyname" type="text" class="form-control" placeholder="companyname" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> linkman</label>
                            <div class="col-xs-9">
                                <input id="linkman" name="linkman" type="text" class="form-control" placeholder="linkman" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> tel</label>
                            <div class="col-xs-9">
                                <input id="tel" name="tel" type="text" class="form-control" placeholder="tel" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> ext1</label>
                            <div class="col-xs-9">
                                <input id="ext1" name="ext1" type="text" class="form-control" placeholder="ext1" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> ext2</label>
                            <div class="col-xs-9">
                                <input id="ext2" name="ext2" type="text" class="form-control" placeholder="ext2" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> ext3</label>
                            <div class="col-xs-9">
                                <input id="ext3" name="ext3" type="text" class="form-control" placeholder="ext3" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> ext4</label>
                            <div class="col-xs-9">
                                <input id="ext4" name="ext4" type="text" class="form-control" placeholder="ext4" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> ext5</label>
                            <div class="col-xs-9">
                                <input id="ext5" name="ext5" type="text" class="form-control" placeholder="ext5" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> ext6</label>
                            <div class="col-xs-9">
                                <input id="ext6" name="ext6" type="text" class="form-control" placeholder="ext6" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">楼栋</label>
                            <div class="col-xs-9">
                                <input id="buildingname" name="buildingname" type="text" class="form-control" placeholder="buildingname" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">楼层</label>
                            <div class="col-xs-9">
                                <input id="floorno" name="floorno" type="text" class="form-control" placeholder="floorno" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
				<!--如果输入元素是奇数个元素，在n=size/2?int时输出2列格式；如果元素是奇数个，需要在n=size/2?int+1时输出2列格式；需要换列，每行最多显示2列-->
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">房源名称</label>
                            <div class="col-xs-9">
                                <input id="housename" name="housename" type="text" class="form-control" placeholder="housename" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> area</label>
                            <div class="col-xs-9">
                                <input id="area" name="area" type="text" class="form-control" placeholder="area" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> fix</label>
                            <div class="col-xs-9">
                                <input id="fix" name="fix" type="text" class="form-control" placeholder="fix" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> basesaleprice</label>
                            <div class="col-xs-9">
                                <input id="basesaleprice" name="basesaleprice" type="text" class="form-control" placeholder="basesaleprice" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> applytype</label>
                            <div class="col-xs-9">
                                <input id="applytype" name="applytype" type="text" class="form-control" placeholder="applytype" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> channelname</label>
                            <div class="col-xs-9">
                                <input id="channelname" name="channelname" type="text" class="form-control" placeholder="channelname" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> channelid</label>
                            <div class="col-xs-9">
                                <input id="channelid" name="channelid" type="text" class="form-control" placeholder="channelid" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> creater</label>
                            <div class="col-xs-9">
                                <input id="creater" name="creater" type="text" class="form-control" placeholder="creater" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> creattime</label>
                            <div class="col-xs-9">
                                <input id="creattime" name="creattime" type="text" class="form-control" placeholder="creattime" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> updater</label>
                            <div class="col-xs-9">
                                <input id="updater" name="updater" type="text" class="form-control" placeholder="updater" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> updattime</label>
                            <div class="col-xs-9">
                                <input id="updattime" name="updattime" type="text" class="form-control" placeholder="updattime" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">申请时间</label>
                            <div class="col-xs-9">
                                <input id="applytime" name="applytime" type="text" class="form-control" placeholder="applytime" />
                            </div>
                        </div>
                    </div>
				</div><!--end 换列-->
            </div><!--end row-->
       </div><!--end body-->

	   <div class="modal-footer bg-info " id='buttonDiv'>
	   </div>
    </div>
    </form>
    <!--------------------------面板 end------------------------------------>

    <!-------------------------- 审核面板  start--------------------------------->
    <form class="form-horizontal form-bordered form-row-strippe" name="shUpdate" id="shUpdate" mentod="post" role="form"
          data-toggle="validator" enctype="multipart/form-data">
        <div class="panel panel-primary">
            <div class="panel-body">
                <div class="row">
                    <h5>&nbsp;&nbsp;审核信息</h5>
                    <hr>
                    <div class="col-xs-6"><!--start 换列-->
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-2">审核意见</label>
                                <div class="col-xs-10">
                                    <textarea name="note" id="note" class="form-control" rows="3"></textarea>
                                    <input id="tninstanceid" name="tninstanceid" type="hidden"/>
                                    <input id="appid" name="appid" type="hidden"/>
                                    <input id="biztype" name="biztype" type="hidden" value=""/>
                                </div>
                            </div>
                        </div>
                        <!--如果输入元素是偶数个元素，在n=size/2?int时输出2列格式；如果元素是奇数个，需要在n=size/2?int时输出2列格式；需要换列，每行最多显示2列-->
                    </div><!--end 换列--><!--start 换列-->
                    <div class="col-xs-6" id="shNoteDiv">
                        <div class="col-xs-12">
                            <div id="checkButtonDiv" class="form-group" style="display: none">
                                <button type="button" class="btn btn-sm btn-success" onclick="shtg()" name="shtgButton"
                                        id="shtgButton">审核通过
                                </button>
                                <button type="button" class="btn btn-sm btn-danger" onclick="shth()" name="shthButton"
                                        id="shthButton">退回
                                </button>
                                <button type="button" class="btn btn-sm btn-primary" onclick="history.go(-1)">返回
                                </button>
                            </div>
                            <div id="hisButtonDiv" class="form-group">
                                <button type="button" class="btn btn-sm btn-primary" onclick="history.go(-1)">返回
                                </button>
                            </div>
                        </div>
                    </div><!--end 换列-->
                </div><!--end row-->
            </div><!--end body-->
        </div>
    </form>
    <!--------------------------审核面板 end------------------------------------>

    <!-------------------------- 流程图信息面板  start--------------------------------->
    <div class="panel panel-primary">
        <div class="panel-body">
            <div class="row">
                <h5>&nbsp;&nbsp;审核流程信息</h5>
                <hr>
                <table id="grid_process" class="table table-condensed table-striped table-bordered table-hover"
                       class="sortable"
                       cellpadding="0" cellspacing="0" border="0" class="display" width="100%">
                    <tbody id="grid_process_body"></tbody>
                </table>

            </div><!--end row-->
        </div><!--end body-->
    </div>
    <!--------------------------流程图信息面板 end------------------------------------>

    <!-------------------------- 历史审核意见面板  start--------------------------------->
    <div class="panel panel-primary">
        <div class="panel-body">
            <div class="row">
                <h5>&nbsp;&nbsp;历史审核信息</h5>
                <hr>
                <table id="grid" class="table table-condensed table-striped table-bordered table-hover" class="sortable"
                       cellpadding="0" cellspacing="0" border="0" class="display" width="100%">
                    <thead id="grid_head">
                    <tr>
                        <th onclick="sortTableT.sort('grid',0,'String')">审核流水号</th>
                        <th onclick="sortTableT.sort('grid',0,'String')">审核时间</th>
                        <th onclick="sortTableT.sort('grid',0,'String')">审核人</th>
                        <th onclick="sortTableT.sort('grid',0,'String')">审核结果</th>
                        <th onclick="sortTableT.sort('grid',0,'String')">审核岗位</th>
                        <th onclick="sortTableT.sort('grid',0,'String')">审核意见</th>
                        <th onclick="sortTableT.sort('grid',0,'String')">流程名称</th>
                    </tr>
                    </thead>
                    <tbody id="grid_body"></tbody>
                </table>

            </div><!--end row-->
        </div><!--end body-->
    </div>
    <!--------------------------历史审核意见面板 end------------------------------------>

  </div>  
  </body>
</html>

<script src="<%=basePath%>js/bootstrap.min.js"></script>
<!--<script src="<%=basePath%>js/jquery-1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrapValidator.js"></script>-->
<script src="<%=basePath%>js/bootstrap-paginator.min.js"></script>
<script src="<%=basePath%>/js/respond.js"></script>
<script src="<%=basePath%>/js/html5.js"></script>
<script src="<%=basePath%>js/toastr/toastr.js"></script>
<script src="<%=basePath%>js/bootbox.js"></script>
<script src="<%=basePath%>js/jquery.validate.js"></script>
<!-- <script src="<%=basePath%>js/additional-methods.min.js"></script> -->
<script src="<%=basePath%>js/my-jquery-curd.js"></script>
<script src="<%= basePath %>js/tableSortTool.js" ></script>
<script src="<%= basePath %>js/calendar.js" ></script>
<script type="text/javascript">
    //审核通过提交表单；
    function shtg() {
        var url = "<%=basePath%>t_bussines_apply/shtgT_bussines_apply?time=" + Math.random();
        bootbox.confirm({
            size: 'small',
            buttons: {
                confirm: {
                    label: '  确认   ',
                    className: 'btn btn-sm btn-danger'
                },
                cancel: {
                    label: '  取消    ',
                    className: 'btn btn-success btn-sm'
                }
            },
            message: '您确认要审核通过？',
            callback: function (result) {
                if (result) { if (result) { myCurdShtg(url); }}
            },
            title: '确认提示：',
            className: ' '
        })
    }

    //审核退回提交表单；
    function shth() {
        var url = "<%=basePath%>t_bussines_apply/shthT_bussines_apply?time=" + Math.random();
        bootbox.confirm({
            size: 'small',
            buttons: {
                confirm: {
                    label: ' 退回 ',
                    className: 'btn btn-sm btn-danger'
                },
                cancel: {
                    label: '   取消     ',
                    className: 'btn btn-success btn-sm'
                }
            },
            message: '您确认要退回？',
            callback: function (result) {
                if (result) {if (result) {myCurdShth(url);}}
            },
            title: '确认提示：',
            className: ' '
        })
    }

    //初始化页面加载表单值；
    $().ready(function () {
        //1、初始化数据显示
        var name = "T_bussines_apply信息";
        var id = '<%=request.getParameter("appid")%>';
        var tninstanceid = '<%=request.getParameter("tninstanceid")%>';
        var oplx = '<%=request.getParameter("oplx")%>';
        //设置审核意见表单默认值；
        $("#tninstanceid").val(tninstanceid);
        $("#appid").val(id);
        var basePath = "<i class='icon-eye-open'></i>&nbsp;";//设置addHeaderDiv标题文字及按钮
        setHeader2("审核" + name, basePath);
        //setButtonDivView2();//设置adddiv的 操作按钮
        var url = "<%=basePath%>t_bussines_apply/getT_bussines_apply?id=" + id + "&time=" + Math.random();
        //alert("url="+url);
        $.getJSON(url, function (data) {//获取数据，并且自动填充form，自动代码待修改； @todo;
            setValue(data);
            //$("#ext3").attr("disabled", true);
            //alert($("#effect_date").val()+""+jsonDateFormat($("#effect_date").val()));
            //$("#effect_date").val(jsonDateFormat($("#effect_date").val())); //重新设置日期类型的值
        });
        formReadOnly2('ffAdd');//设置表单不可修改; 会影响所有表单输入框；

        //如果是审核进来的；还是查看历史任务进来的；现实不同按钮
        if (oplx == 'check') {
            $("#checkButtonDiv").show();
            $("#hisButtonDiv").hide();
            $("#note").removeAttr("readOnly");
        } else if (oplx == 'his') {
            $("#checkButtonDiv").hide();
            $("#hisButtonDiv").show();
            $("#note").attr("readOnly", "true");
        }
        //加载审核流程信息
        SearchTaskNodes(0);
    }) //end funciton read;

    //加载历史审核意见并显示
    function SearchTaskNodes(startIndex) {
        var taskid = '<%=request.getParameter("taskid")%>';
        var pageSize = 1000;
        //var condition = $("#form1").serialize();
        var url = "<%=basePath%>t_task_node/getAllT_task_node?startIndex=0&pageSize=" + pageSize + "&taskid=" + taskid + "&time=" + Math.random();
        //alert(url);
        $.getJSON(url, function (data) {
            $("#totalCount").html(data.totalCount);
            $("#totalPageNo").html(data.totalPageNo);
            $("#grid_body").html("");
            var str = "<tr>";
            //1、表格行内容输出; 倒序输出，因为后台是倒序取得数据；
            $.each(data.items.reverse(), function (i, item) {
                str += "<td width='100px'>" + doNull(item.ext5) + "<br>" + doNull(item.nodename) + "<br>" + doNull(item.userid) + "</td>";
                if (i != data.items.length - 1) {
                    str += "<td  width='50px' valign='middle' align='center'><br><img src='<%=basePath%>/images/jiantou3.jpg' width='30px' height='30px' ></td>"
                }
            });//end each data;
            str += "</tr>";
            $("#grid_process_body").append(str);
            //加载历史审核意见
            Search(0);
        })//end getJSON;
    }

    //加载历史审核意见并显示
    function Search(startIndex) {
        var instanceid = '<%=request.getParameter("instanceid")%>';
        var pageSize = 1000;
        //var condition = $("#form1").serialize();
        var url = "<%=basePath%>workflow/getTaskNodeInstanceNoteList?startIndex=0&pageSize=" + pageSize + "&instanceid=" + instanceid + "&tninstancestatus=1,2&time=" + Math.random();
        //alert(url);
        $.getJSON(url, function (data) {
            //$("#pageSize").html(data.pageSize);
            $("#totalCount").html(data.totalCount);
            $("#totalPageNo").html(data.totalPageNo);
            $("#grid_body").html("");
            //1、表格行内容输出
            $.each(data.items, function (i, item) {
                var str = "<tr>";
                str += "<td>" + doNull(item.tninstanceid) + "</td>";
                str += "<td>" + doNull(item.updatetime) + "</td>";
                str += "<td>" + doNull(item.updater) + "</td>";
                if (item.tninstancestatus == 0) {
                    str += "<td><span class='label label-success'>审批中</span></td>";
                } else if (item.tninstancestatus == 1) {
                    str += "<td><span class='label label-success'>通过</span></td>";
                } else if (item.tninstancestatus == 2) {
                    str += "<td><span class='label label-danger'>已退回</span></td>";
                } else {
                    str += "<td><span class='label label-danger'></span></td>";
                }
                str += "<td>" + doNull(item.laststep) + "</td>";
                str += "<td>" + doNull(item.note) + "</td>";
                str += "<td>" + doNull(item.firststep) + "</td>";
                str += "</tr>";
                $("#grid_body").append(str);
            });//end each data;
        })//end getJSON;
    }
</script>
